/*
 * Copyright (C) 2023 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.templateproject.activity;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemChildClickListener;
import com.xuexiang.templateproject.adapter.SubjectAddAdapter;
import com.xuexiang.templateproject.adapter.SubjectShowAdapter;
import com.xuexiang.templateproject.bean.PageCourse;
//import com.google.android.gms.common.internal.ServiceSpecificExtraArgs;
//import com.jcds.learneasy.R;
//import com.jcds.learneasy.base.LnBaseActivity;
//import com.jcds.learneasy.entity.PageCourse;
//import com.jcds.learneasy.entity.SubjectManagerEntity;
//import com.jcds.learneasy.ui.activity.SubjectManagerActivity;
//import com.jcds.learneasy.ui.adapter.SubjectAddAdapter;
//import com.jcds.learneasy.ui.adapter.SubjectShowAdapter;
//import d.m.b.f.y;
//import d.m.b.g.j0;
//import d.m.b.j.c0;
import com.xuexiang.templateproject.R;
import com.xuexiang.templateproject.bean.SubjectManagerEntity;
import com.xuexiang.templateproject.core.BaseActivity;
import com.xuexiang.templateproject.databinding.ActivityMainBinding;
import com.xuexiang.templateproject.databinding.ActivityProjectManagerBinding;
import com.xuexiang.templateproject.presenter.SubjectManagerPresenter;
import com.xuexiang.templateproject.view.SubjectContract;
import com.xuexiang.templateproject.widget.BottomDialog;

import java.util.LinkedHashMap;
import java.util.Map;
import kotlin.Lazy;
import kotlin.LazyKt;
import kotlin.Metadata;
import kotlin.jvm.functions.Function0;
import kotlin.jvm.internal.Intrinsics;
import kotlin.jvm.internal.Lambda;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/* compiled from: SubjectManagerActivity.kt */
//@Metadata(d1 = {"\u0000Z\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0006\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0000\n\u0002\u0010\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0004\u0018\u00002\u00020\u00012\u00020\u0002B\u0005¢\u0006\u0002\u0010\u0003J\u0010\u0010\u0019\u001a\u00020\u001a2\u0006\u0010\u001b\u001a\u00020\u001cH\u0002J\b\u0010\u001d\u001a\u00020\u001eH\u0014J\u0010\u0010\u001f\u001a\u00020 2\u0006\u0010!\u001a\u00020\"H\u0016J\b\u0010#\u001a\u00020$H\u0014J\b\u0010%\u001a\u00020 H\u0016J\b\u0010&\u001a\u00020 H\u0016J\b\u0010'\u001a\u00020 H\u0016R\u0010\u0010\u0004\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u0010\u0010\u0006\u001a\u0004\u0018\u00010\u0007X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\b\u001a\u00020\t8BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\f\u0010\r\u001a\u0004\b\n\u0010\u000bR\u0010\u0010\u000e\u001a\u0004\u0018\u00010\u0005X\u0082\u000e¢\u0006\u0002\n\u0000R\u001b\u0010\u000f\u001a\u00020\u00108BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0013\u0010\r\u001a\u0004\b\u0011\u0010\u0012R\u001b\u0010\u0014\u001a\u00020\u00158BX\u0082\u0084\u0002¢\u0006\f\n\u0004\b\u0018\u0010\r\u001a\u0004\b\u0016\u0010\u0017¨\u0006("}, d2 = {"Lcom/jcds/learneasy/ui/activity/SubjectManagerActivity;", "Lcom/jcds/learneasy/base/LnBaseActivity;", "Lcom/jcds/learneasy/contract/SubjectContract$SubjectView;", "()V", "mAddGridLayoutManager", "Landroidx/recyclerview/widget/GridLayoutManager;", "mBottomDialog", "Lcom/jcds/learneasy/dialog/BottomDialog;", "mPresenter", "Lcom/jcds/learneasy/presenter/SubjectManagerPresenter;", "getMPresenter", "()Lcom/jcds/learneasy/presenter/SubjectManagerPresenter;", "mPresenter$delegate", "Lkotlin/Lazy;", "mShowGridLayoutManager", "mSubjectAddAdapter", "Lcom/jcds/learneasy/ui/adapter/SubjectAddAdapter;", "getMSubjectAddAdapter", "()Lcom/jcds/learneasy/ui/adapter/SubjectAddAdapter;", "mSubjectAddAdapter$delegate", "mSubjectShowAdapter", "Lcom/jcds/learneasy/ui/adapter/SubjectShowAdapter;", "getMSubjectShowAdapter", "()Lcom/jcds/learneasy/ui/adapter/SubjectShowAdapter;", "mSubjectShowAdapter$delegate", "getFooterView", "Landroid/view/View;", ServiceSpecificExtraArgs.CastExtraArgs.LISTENER, "Landroid/view/View$OnClickListener;", "getLayoutId", "", "getSubjectSuccess", "", "subjectManagerEntity", "Lcom/jcds/learneasy/entity/SubjectManagerEntity;", "getTitleText", "", "initData", "initEvent", "initView", "app_huaweiRelease"}, k = 1, mv = {1, 7, 1}, xi = 48)
/* loaded from: classes2.dex */
public final class SubjectManagerActivity extends BaseActivity<ActivityProjectManagerBinding> implements SubjectContract {
    @Nullable

    /* renamed from: b  reason: collision with root package name */
    public GridLayoutManager f4244b;
    @Nullable

    /* renamed from: c  reason: collision with root package name */
    public GridLayoutManager f4245c;
    @Nullable

    /* renamed from: d  reason: collision with root package name */
    public BottomDialog mBottomDialog;
    @NotNull

    /* renamed from: h  reason: collision with root package name */
    public Map<Integer, View> f4250h = new LinkedHashMap();
    @NotNull



    @Override
    protected ActivityProjectManagerBinding viewBindingInflate(LayoutInflater inflater) {
        return ActivityProjectManagerBinding.inflate(inflater);
    }


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        initView();

        initData();

        initEvent();
    }

    @Override
    public void bizError(@NonNull String str, int i2) {

    }

    @Override
    public void dismissLoading() {

    }

    @NonNull
    @Override
    public Context getContext() {
        return null;
    }

    @Override
    public void showLoading() {

    }

    public final class OnSaveOnClickListener implements BottomDialog.OnSaveOnClickListener {

        /* renamed from: b  reason: collision with root package name */
        public final /* synthetic */ PageCourse pageCourse;

        public OnSaveOnClickListener(PageCourse pageCourse) {
            this.pageCourse = pageCourse;
        }

        @Override // d.m.b.g.j0.a
        public void onSaveClick(@NotNull String subjectName) {
            Intrinsics.checkNotNullParameter(subjectName, "subjectName");
            SubjectManagerActivity.this.getMPresenter().saveCourse(2, this.pageCourse.getCourseId(), subjectName);
        }
    }

    public final class b implements BottomDialog.OnSaveOnClickListener {
        public b() {
        }

        @Override // d.m.b.g.j0.a
        public void onSaveClick(@NotNull String subjectName) {
            Intrinsics.checkNotNullParameter(subjectName, "subjectName");
            SubjectManagerActivity.this.getMPresenter().saveCourse(0, subjectName);
        }
    }

    public SubjectManagerActivity() {
        getMPresenter().attachView(this);
    }

    public final void P0(SubjectManagerActivity this$0, BaseQuickAdapter baseQuickAdapter, View view, int i2) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        Intrinsics.checkNotNullParameter(baseQuickAdapter, "<anonymous parameter 0>");
        Intrinsics.checkNotNullParameter(view, "view");
        PageCourse pageCourse = this$0.getSubjectShowAdapter().getData().get(i2);
        int id = view.getId();
        if (id == R.id.ivEdit) {
            BottomDialog j0Var = new BottomDialog(this$0, new OnSaveOnClickListener(pageCourse));
            this$0.mBottomDialog = j0Var;
            if (j0Var != null) {
                j0Var.updateCourseName(pageCourse.getCourseName());
            }
            BottomDialog j0Var2 = this$0.mBottomDialog;
            Intrinsics.checkNotNull(j0Var2);
            if (!j0Var2.isShowing()) {
                BottomDialog j0Var3 = this$0.mBottomDialog;
                Intrinsics.checkNotNull(j0Var3);
                j0Var3.show();
            }
        } else if (id == R.id.ivTag) {
            this$0.getMPresenter().saveCourse(-1, pageCourse.getCourseId());
        }
    }

    public static final void Q0(SubjectManagerActivity this$0, BaseQuickAdapter baseQuickAdapter, View view, int i2) {

        if (view.getId() == R.id.ivTag) {
            this$0.getMPresenter().saveCourse(1, this$0.getSubjectAddAdapter().getData().get(i2).getCourseId());
        }
    }

    public final void R0(SubjectManagerActivity this$0, View view) {
        Intrinsics.checkNotNullParameter(this$0, "this$0");
        BottomDialog j0Var = new BottomDialog(this$0, new b());
        this$0.mBottomDialog = j0Var;
        Intrinsics.checkNotNull(j0Var);
        if (!j0Var.isShowing()) {
            BottomDialog j0Var2 = this$0.mBottomDialog;
            Intrinsics.checkNotNull(j0Var2);
            j0Var2.show();
        }
    }

    public final View L0(View.OnClickListener onClickListener) {
        View inflate = getLayoutInflater().inflate(R.layout.footer_view, (ViewGroup) ((RecyclerView) _$_findCachedViewById(R.id.recyclerViewAdd)), false);
        Intrinsics.checkNotNullExpressionValue(inflate, "layoutInflater.inflate(R…, recyclerViewAdd, false)");
        inflate.setOnClickListener(onClickListener);
        return inflate;
    }
    private SubjectShowAdapter mSubjectShowAdapter = null;
    private SubjectAddAdapter mSubjectAddAdapter = null;
    public final SubjectManagerPresenter getMPresenter() {
//        return (SubjectManagerPresenter) this.f4247e.getValue();
        return new SubjectManagerPresenter();
    }

    public final SubjectAddAdapter getSubjectAddAdapter() {
        if(mSubjectAddAdapter==null){
            mSubjectAddAdapter = new SubjectAddAdapter(R.layout.item_subject_view);
        }
        return mSubjectAddAdapter;
    }

    public final SubjectShowAdapter getSubjectShowAdapter() {
        if(mSubjectShowAdapter==null){
            mSubjectShowAdapter = new SubjectShowAdapter(R.layout.item_subject_view);
        }
        return mSubjectShowAdapter;
    }

     public void _$_clearFindViewByIdCache() {
        this.f4250h.clear();
    }
     @Nullable
    public View _$_findCachedViewById(int i2) {
        Map<Integer, View> map = this.f4250h;
        View view = map.get(Integer.valueOf(i2));
        if (view != null) {
            return view;
        }
        View findViewById = findViewById(i2);
        if (findViewById == null) {
            return null;
        }
        map.put(Integer.valueOf(i2), findViewById);
        return findViewById;
    }

    @Override // d.m.b.f.y
    public void getSubjectSuccess(@NotNull SubjectManagerEntity subjectManagerEntity) {
        Intrinsics.checkNotNullParameter(subjectManagerEntity, "subjectManagerEntity");
        BottomDialog j0Var = this.mBottomDialog;
        if (j0Var != null) {
            Intrinsics.checkNotNull(j0Var);
            if (j0Var.isShowing()) {
                BottomDialog j0Var2 = this.mBottomDialog;
                Intrinsics.checkNotNull(j0Var2);
                j0Var2.dismiss();
            }
        }
        getSubjectShowAdapter().setList(subjectManagerEntity.getHomepageCourseList());
        getSubjectAddAdapter().setList(subjectManagerEntity.getNoHomepageCourseList());
    }


    @NotNull
    public String getTitleText() {
        String string = getResources().getString(R.string.project_manager_title);
        return string;
    }

    public void initData() {
        getMPresenter().queryAllCourse();
    }


    public void initEvent() {
        getSubjectShowAdapter().addChildClickViewIds(R.id.ivTag, R.id.ivEdit);
        getSubjectShowAdapter().setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override // d.f.a.a.a.f.b
            public void onItemChildClick(BaseQuickAdapter baseQuickAdapter, View view, int i2) {
                SubjectManagerActivity.this.P0(SubjectManagerActivity.this, baseQuickAdapter, view, i2);
            }
        });
        getSubjectAddAdapter().addChildClickViewIds(R.id.ivTag);
        getSubjectAddAdapter().setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override // d.f.a.a.a.f.b
            public final void onItemChildClick(BaseQuickAdapter baseQuickAdapter, View view, int i2) {
                SubjectManagerActivity.Q0(SubjectManagerActivity.this, baseQuickAdapter, view, i2);
            }
        });
    }

    public void initView() {

//        setTooBarBackground(R.color.white);
        int i2 = R.id.recyclerView;
        ((RecyclerView) _$_findCachedViewById(i2)).setAdapter(getSubjectShowAdapter());
        this.f4244b = new GridLayoutManager(this, 3);
        ((RecyclerView) _$_findCachedViewById(i2)).setLayoutManager(this.f4244b);
        this.f4245c = new GridLayoutManager(this, 3);
        int i3 = R.id.recyclerViewAdd;
        ((RecyclerView) _$_findCachedViewById(i3)).setAdapter(getSubjectAddAdapter());
        ((RecyclerView) _$_findCachedViewById(i3)).setLayoutManager(this.f4245c);
        View L0 = L0(new View.OnClickListener() { // from class: d.m.b.l.a.c4
            @Override // android.view.View.OnClickListener
            public final void onClick(View view) {
//                SubjectManagerActivity.R0(SubjectManagerActivity.this, view);
            }
        });
        ViewGroup.LayoutParams layoutParams = L0.getLayoutParams();
//        BaseQuickAdapter.h(getSubjectAddAdapter(), L0, 0, 0, 4, null);
        ViewGroup.LayoutParams layoutParams2 = L0.getLayoutParams();
//        Intrinsics.checkNotNull(layoutParams2, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
//        Intrinsics.checkNotNull(layoutParams, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
        ViewGroup.MarginLayoutParams marginLayoutParams = (ViewGroup.MarginLayoutParams) layoutParams;
        ((ViewGroup.MarginLayoutParams) layoutParams2).topMargin = marginLayoutParams.topMargin;
        ViewGroup.LayoutParams layoutParams3 = L0.getLayoutParams();
//        Intrinsics.checkNotNull(layoutParams3, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
        ((ViewGroup.MarginLayoutParams) layoutParams3).bottomMargin = marginLayoutParams.bottomMargin;
        ViewGroup.LayoutParams layoutParams4 = L0.getLayoutParams();
//        Intrinsics.checkNotNull(layoutParams4, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
        ((ViewGroup.MarginLayoutParams) layoutParams4).leftMargin = marginLayoutParams.leftMargin;
        ViewGroup.LayoutParams layoutParams5 = L0.getLayoutParams();
//        Intrinsics.checkNotNull(layoutParams5, "null cannot be cast to non-null type android.view.ViewGroup.MarginLayoutParams");
        ((ViewGroup.MarginLayoutParams) layoutParams5).rightMargin = marginLayoutParams.rightMargin;
    }

}